package com.itheima.test;

public class Demo03 {
    public static void main(String[] args) {
     /*   A a = new A();
        String s = a.toString();//com.itheima.test.A@b4c966a
        System.out.println(s);
        Class aClass = a.getClass();
        A a1 = new A();
        Class aClass1 = a1.getClass();
        System.out.println(aClass==aClass1);*/
      /*  A a = new A();
        String s = a.toString();//com.itheima.test.A@b4c966a
        System.out.println(s);
        Class aClass = a.getClass();
        String name = aClass.getName();
        System.out.println(name);
        int i = a.hashCode();
        System.out.println(i);
        System.out.println(Integer.toHexString(i));*/

        Student zhangsan = new Student("zhangsan", 18);
        //zhangsan=null;
        System.out.println(zhangsan);//打印对象
        String s = zhangsan.toString();
        System.out.println(s);//打印字符串
    }

}

class A{

}
class Student{
    private String name;
    private int age;


    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        /*if(! (o instanceof Student)){
            return false;
        }*/
        Student student = (Student) o;

        if (age != student.age) return false;
        return name != null ? name.equals(student.name) : student.name == null;
    }

}
